//
//  PPMineInfoCell.m
//  PPDL
//
//  Created by 王洋 on 2019/7/30.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "PPMineInfoCell.h"

@interface PPMineInfoCell ()

//用户头像
@property (weak, nonatomic) IBOutlet UIImageView *userIcon;

//用户昵称
@property (weak, nonatomic) IBOutlet UILabel *userName;

//实名审核状态
@property (weak, nonatomic) IBOutlet UIButton *user_shiming;


@end

@implementation PPMineInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.userIcon.userInteractionEnabled = YES;
    [self.userIcon addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (self.mineInfocellClickBlock) {
            self.mineInfocellClickBlock(Mine_Go_UserInfo);
        }
    }];
}

- (void)fillCellWithModel:(PPMineInfoModel *)model {
    
    [self.userIcon sd_setImageWithURL:[NSURL URLWithString:model.userIconUrl] placeholderImage:[UIImage imageNamed:@"placeholder_rect"] options:SDWebImageRetryFailed];
    self.userName.text =[NSString stringWithFormat:@"%@",model.userName.length?model.userName:@"XXX"];
    
    if (model.isRealNameAuth) {
        [self.user_shiming setImage:[UIImage imageNamed:@"mine_yishiming"] forState:UIControlStateNormal];
        [self.user_shiming setTitle:@" 已实名" forState:UIControlStateNormal];
    } else {
        [self.user_shiming setImage:[UIImage imageNamed:@"mine_weishiming"] forState:UIControlStateNormal];
        [self.user_shiming setTitle:@" 未实名" forState:UIControlStateNormal];
    }
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    
    self.userIcon.layer.cornerRadius = self.userIcon.frame.size.width/2;
    
//    WEAKSELF
//    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//        
////        weakSelf.userIcon.layer.cornerRadius =  weakSelf.userIcon.frame.size.width/2;
//        
//        [weakSelf.userIcon pp_clipCorners:UIRectCornerAllCorners radius:weakSelf.userIcon.frame.size.width/2];
//    });

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
